package com.kingland.Weidezhan.controller;


import com.kingland.Weidezhan.Service.LbDoctorimpl;
import com.kingland.Weidezhan.model.UserModel;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


@RestController
public class DoctorController {
    private LbDoctorimpl lbDoctorimpl;

    public DoctorController(LbDoctorimpl lbDoctorimpl){
        this.lbDoctorimpl=lbDoctorimpl;
    }
    @GetMapping("/list")
    public List<UserModel> list(HttpServletRequest request, HttpServletResponse response){
        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
        response.setHeader("Access-Control-Allow-Credentials", "true");
        response.setHeader("P3P", "CP=CAO PSA OUR");
        if (request.getHeader("Access-Control-Request-Method") != null && "OPTIONS".equals(request.getMethod())) {
            response.addHeader("Access-Control-Allow-Methods", "POST,GET,TRACE,OPTIONS");
            response.addHeader("Access-Control-Allow-Headers", "Content-Type,Origin,Accept");
            response.addHeader("Access-Control-Max-Age", "120");
        }
        return this.lbDoctorimpl.selectAll();
    }
}
